package com.itheima.service.impl;

import com.itheima.dao.BookDao;
import com.itheima.dao.UserDao;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

//定义bean,后面添加bean的id
@Service("userService")
//定义bean的作用域
@Scope("singleton")
public class UserServiceImpl implements UserService {
    @Value("1")
    private int num;
    @Value("haha")
    private String version;

    @Autowired
    @Qualifier
    private UserDao userDao;

    @Autowired
    private BookDao bookDao;

    public UserServiceImpl(){
        System.out.println("service running ...");
    }

    public void save() {
        System.out.println("user service running...");
    }
    @PostConstruct
    public void init(){
        System.out.println("user servier init...");
    }
    @PreDestroy
    public void destroy(){
        System.out.println("user servier destroy...");
    }

}
